package main

import (
	"context"
	"encoding/json"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	risk "git.900sui.cn/kc/rpcinterface/client/risk"
	"git.900sui.cn/kc/rpcinterface/interface/task"
	"github.com/streadway/amqp"
)

func main() {
	rpcbbaa := new(risk.BusBasicAccumulative).Init()
	defer rpcbbaa.Close()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("risk.log.addDelGoods"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("risk.queue.addDelGoods"), func(msg amqp.Delivery) {
		args := task.ArgsAddDelGoods{}
		if err := json.Unmarshal(msg.Body,&args);err!=nil{
			return
		}
		rpcRisk := new(risk.BusBasicIndusAvg).Init()
		defer rpcRisk.Close()
		reply := false
		if err := rpcRisk.RiskForAddDelGoods(context.Background(),&args,&reply);err!= nil{
			utils.Logerr.Printf("统计行业产品/卡项/商品总数任务失败，args ：%#v err: %s \n",args,err.Error())
		}
		// 预付卡风险管理系统  卡项/商品总数
		if err := rpcbbaa.AddGoodsNumRpc(context.Background(),&args,&reply);err != nil {
			utils.Logerr.Printf("统计风空管理系统 /卡项/商品总数任务失败，args ：%#v err: %s \n",args,err.Error())
		}
	})
	if err != nil {
		panic(err)
	}
}
